<template>
  <button @click="show= !show">显示/隐藏</button>
  <transition name="slide">
      <div v-if="show" class="dv">滑动进入效果</div>
  </transition>
</template>

<script setup>
import { ref } from 'vue';

let show = ref(false)
</script>

<style>
.dv{
    margin-top: 20px;
    padding: 30px;
    width: 200px;
    background-color: deeppink;
    color: darkkhaki;
}
.slide-enter-active
 {
  transition: all 1s ease-out;
}
.slide-leave-active{
    transition: all 1s ease-in;
}
.slide-enter-from
 {
  opacity: 0;
  transform: translateX(-100px);
}
.slide-leave-to{
    opacity: 0;
    transform: translateX(-100px);
}
</style>